/**
 * @file 地图类型索引文件
 * @description 统一导出所有地图相关类型定义
 * @date 2024-07-15
 */

import { Timestamp } from './common';

/**
 * 基础地理坐标接口
 */
export interface GeoCoordinate {
  longitude: number;
  latitude: number;
}

/**
 * 位置坐标接口
 * 兼容百度地图等使用lng/lat的API
 */
export type Position = {
  lng: number;
  lat: number;
};

/**
 * 地址信息接口
 */
export interface AddressInfo {
  address?: string;
  city?: string;
  district?: string;
  province?: string;
  street?: string;
  streetNumber?: string;
}

/**
 * 包含地址信息的位置接口
 * 统一表示带地址信息的位置，可用于设备位置、告警位置等
 */
export interface LocationWithAddress extends GeoCoordinate, AddressInfo {
  updateTime?: Timestamp;
}

/**
 * UniApp地图标记点类型
 */
export interface MapMarker {
  id: number;
  latitude: number;
  longitude: number;
  title?: string;
  iconPath: string;
  width: number;
  height: number;
  anchor?: {
    x: number;
    y: number;
  };
  callout?: {
    content: string;
    color?: string;
    fontSize?: number;
    borderRadius?: number;
    bgColor?: string;
    padding?: number;
    display?: 'ALWAYS' | 'BYCLICK';
  };
  label?: {
    content: string;
    color?: string;
    fontSize?: number;
    anchorX?: number;
    anchorY?: number;
    borderWidth?: number;
    borderColor?: string;
    borderRadius?: number;
    bgColor?: string;
    padding?: number;
  };
  alpha?: number;
  zIndex?: number;
  rotate?: number;
}

/**
 * UniApp地图折线类型
 */
export interface MapPolyline {
  points: Array<{
    latitude: number;
    longitude: number;
  }>;
  color?: string;
  width?: number;
  dottedLine?: boolean;
  arrowLine?: boolean;
  borderColor?: string;
  borderWidth?: number;
}

/**
 * UniApp地图多边形类型
 */
export interface MapPolygon {
  points: Array<{
    latitude: number;
    longitude: number;
  }>;
  strokeWidth?: number;
  strokeColor?: string;
  fillColor?: string;
  zIndex?: number;
}

/**
 * UniApp地图组件属性类型
 */
export interface MapProps {
  latitude: number;
  longitude: number;
  scale?: number;
  markers?: MapMarker[];
  polyline?: MapPolyline[];
  polygons?: MapPolygon[];
  circles?: Array<{
    latitude: number;
    longitude: number;
    color?: string;
    fillColor?: string;
    radius: number;
    strokeWidth?: number;
  }>;
  showLocation?: boolean;
  showCompass?: boolean;
  enableRotate?: boolean;
  enable3D?: boolean;
  showScale?: boolean;
  enableTraffic?: boolean;
  enableSatellite?: boolean;
}